﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinKeyBoard.Helpers;

namespace WinKeyBoard.UcControls
{
    public partial class UcFrmSettings : UIUserControl
    {
        public UcFrmSettings()
        {
            InitializeComponent();
        }
        //初始化
        private void UcFrmSettings_Load(object sender, EventArgs e)
        {
            InitChkState();
        }

        private void InitChkState()
        {
            string AutoStart = IniHelper.ReadValue(Sections.AutoStart);
            chkAutoStart.Checked = AutoStart == "0" ? false : true;

            string StartDock = IniHelper.ReadValue(Sections.StartDock);
            chkStartDock.Checked = StartDock == "0" ? false : true;

            string Minimized = IniHelper.ReadValue(Sections.Minimized);
            chkMinimized.Checked = Minimized == "0" ? false : true;

            string CloseWarn = IniHelper.ReadValue(Sections.CloseWarn);
            chkCloseWarn.Checked = CloseWarn == "0" ? false : true;
        }

        //自启动
        private void chkAutoStart_CheckedChanged(object sender, EventArgs e)
        {
            var value = chkAutoStart.Checked;
            IniHelper.WriteValue(Sections.AutoStart, value ? "1" : "0");

            ComputerHelper.SetMeAutoStart(value);
        }
        //启动后靠边隐藏
        private void chkStartDock_CheckedChanged(object sender, EventArgs e)
        {
            var value = chkStartDock.Checked;
            IniHelper.WriteValue(Sections.StartDock, value ? "1" : "0");

        }
        //关闭时，最小化
        private void chkMinimized_CheckedChanged(object sender, EventArgs e)
        {
            var value = chkMinimized.Checked;
            IniHelper.WriteValue(Sections.Minimized, value ? "1" : "0");
        }

        //关闭时，提醒
        private void chkCloseWarn_CheckedChanged(object sender, EventArgs e)
        {
            var value = chkCloseWarn.Checked;
            IniHelper.WriteValue(Sections.CloseWarn, value ? "1" : "0");
        }

        
        


    }
}
